CMAKE_MINIMUM_REQUIRED(VERSION 3.16)
SET(PROJECT_NAME ACO)
PROJECT(${PROJECT_NAME})

#可执行文件生成路径
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/build)
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
    SET(Qt6_DIR D:/Qt/6.2.4/mingw_64/lib/cmake/Qt6)
ENDIF ()

#开启MOC、RCC和UIC，则会在预处理之前先进行MOC、RCC和UIC操作
SET(CMAKE_AUTOMOC ON)
SET(CMAKE_AUTORCC ON)
SET(CMAKE_AUTOUIC ON)
SET(CMAKE_CXX_STANDARD 11)

IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
    FIND_PACKAGE(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
    FIND_PACKAGE(Qt6 COMPONENTS Core Gui Widgets REQUIRED)
ENDIF ()

INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src)

FILE(GLOB_RECURSE SOURCE_FILES "${PROJECT_SOURCE_DIR}/src/*.cpp" "${PROJECT_SOURCE_DIR}/src/*.ui")
ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCE_FILES})

IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
    MESSAGE(STATUS "current platform: Linux ")
    TARGET_LINK_LIBRARIES(${PROJECT_NAME} Qt5::Core Qt5::Gui Qt5::Widgets)
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
    MESSAGE(STATUS "current platform: Windows")
    TARGET_LINK_LIBRARIES(${PROJECT_NAME} Qt6::Widgets)
ELSE ()
    MESSAGE(STATUS "Unsupport platform: ${CMAKE_SYSTEM_NAME}")
ENDIF ()